{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "using Seismic, PyPlot # required deps"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAgUAAAIOCAYAAAAoW37OAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAPYQAAD2EBqD+naQAAH9JJREFUeJzt3X+Q1fV97/HXWdiVH7IoQncBUdDUX/mBQgNoTAxBA8lNdayWKw3Nj/GPzEDKIE7ttDdS7U0nZTojQyM2dTqmtalgx9wmto3h3uzUSBPiD4gkvRLjVowxZjdCBGRBQDj3D7/lZkdDzqkL3/2yj8fMmUnOfnZ58zl7/D75nl+1er1eDwAw5LWUPQAAMDiIAgAgiSgAAAqiAABIIgoAgIIoAACSiAIAoCAKAIAkogAAKIgCACBJyVGwdu3aTJs2LSNHjsycOXPy+OOPlzkOAAxppUXB/fffn5tvvjm33357vvvd72b69OmZP39+duzYUdZIADCk1cr6QKQ5c+Zk9uzZWbNmTZKkXq9nypQpWbZsWW655ZYyRgKAIa2UMwWHDh3K5s2bM2/evKPX1Wq1XHnlldm0aVMZIwHAkDe8jD90x44dOXz4cDo6Ovpd39HRkaeffvpN12/YsCFTp07NyJEjT9SYAFB5+/fvz3PPPZf58+dn/Pjxx1xbShQ0a8OGDVm8eHHZYwBAZX3pS1/KRz/60WOuKSUKxo8fn2HDhqW3t7ff9b29vens7HzD+qlTpyZJvvR3f5cLL7jgRIzIL7hpxYqsvuOOsscYkux9eex9eez9wNr2gx9k8e/+7tFj6bGUEgWtra2ZOXNmurq6cvXVVyd5/YmGXV1dWbZs2RvW/+dDBhdecEFmzJhxQmclGTt2rH0vib0vj70vj70/Php5+L20hw9WrFiRT3ziE5k5c2ZmzZqV1atXZ9++ffnEJz5R1kgAMKSVFgULFy7Mjh07snLlyvT29ubiiy/Oh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HrrrfnIRz6SJLn33nvT0dGRr3zlK1m4cOHxGAcAaMBxOVPwzDPPZPLkyTn33HOzePHi/PjHP06SbN++PT09PZk3b97Rte3t7Zk9e3Y2bdp0PEYBABo04FEwZ86c/M3f/E02bNiQL3zhC9m+fXve9773pa+vLz09PanVauno6Oj3PR0dHenp6RnoUQCAJgz4wwfz588/+r/f8Y53ZNasWTn77LPzD//wD7ngggve0s++acWKjB07tt91i264IYsWLXpLPxcATgbr1q3LuvXr+123e/fuhr//uDyn4BeNHTs25513Xrq7u/P+978/9Xo9vb29/c4W9Pb25pJLLvmVP2v1HXdkxowZx3NcAKisRYsWveEfylu2bMnMd7+7oe8/7u9TsHfv3nR3d2fSpEmZNm1aOjs709XVdfTre/bsyaOPPprLLrvseI8CABzDgEfB7//+7+eRRx7Jj370o3z729/Otddem9bW1txwww1JkuXLl+ezn/1s/umf/inf//7387GPfSxnnnlmrrnmmoEeBQBowoA/fPDCCy/kd37nd7Jz585MmDAhl19+eb7zne/kjDPOSJLccsst2bdvXz71qU9l165dee9735uHHnoobW1tAz0KANCEAY+CdevW/co1t912W2677baB/qMBgLfAZx8AAElEAQBQEAUAQJIT8D4FA6leXACAxjRz3KxYFNRST63sMQCgMpo5blYqCpJacQEAGtP4cdNzCgCAJKIAACiIAgAgiSgAAAqVeqJhvf76BQBoTDPHzcpFwZEjZU/BL6rVhBoMZu6jnNRR4Jd7cHF7wODmPspJGwWHDiUHD5Y9BQBUx6FDja+tVBTs25fs3Vv2FABQHfv2Nb62UlHgTAEANOekPVPQ25ucdlrZUwBAdfT2Nr62UlGwe3eyc2fZUwBAdeze3fjaSkXBM88kfX1lTwEA1fHii42vrVQUfOc7yamnlj0FAFRHM0/Qr1QUvPJKX1577ZWyxwCAyti/v/FT7JWKghdf/L8ZNszLDwCgUYcPP9Pw2kpFwb59O5KMKXsMAKiQHQ2vrFQUJNuT7C97CACokJ6GV1YsCp5J8lLZQwBAhexqeGXFouCMJOPLHgIAKmRYwysrFgWXJJla9h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CACCJKAAACqIAAEgiCgCAgigAAJKIAgCgIAoAgCSiAAAoiAIAIIkoAAAKogAASCIKAIBC01GwcePGXH311Zk8eXJaWlry4IMPvmHNypUrM2nSpIwaNSpXXXVVuru7+339wIEDWbp0acaPH58xY8bk+uuvz89+9rNf+WfXXVxcXFxcXJq+NGp4E2uTJH19fbn44otz44035rd+67fe8PVVq1blzjvvzL333pupU6fmM5/5TObPn59t27alra0tSbJ8+fI89NBD+fKXv5z29vYsXbo01113XTZu3HjMP7ueWuqpNTsyAAxZzRw3m46CBQsWZMGCBa//QfU39seaNWty66235iMf+UiS5N57701HR0e+8pWvZOHChdmzZ0/uueeerF+/PldccUWS5Itf/GIuvPDCPPbYY5k1a1azIwEAA6DpKDiW7du3p6enJ/PmzTt6XXt7e2bPnp1NmzZl4cKFeeKJJ/Laa6/1W3P++efnrLPOyqZNm44ZBbXiAgA0ppnj5oBGQU9PT2q1Wjo6Ovpd39HRkZ6eniRJb29v2tra0t7e/kvX/HLNPjoCAENd48fNAY2C482ZAgBoTmlnCjo7O1Ov19Pb29vvbEFvb28uueSSo2sOHjyYPXv29Dtb0Nvbm87OzmP+/JtWrMjYsWP7XbfohhuyaNGiAfxbAEA1rVu3LuvWr+933e7duxv+/gGNgmnTpqWzszNdXV1517velSTZs2dPHn300SxdujRJMnPmzAwfPjxdXV259tprkyRPP/10nn/++Vx66aXH/Pmr77gjM2bMGMiRAeCksWjRojf8Q3nLli2Z+e53N/T9/6WXJHZ3dx995cGzzz6brVu3Zty4cZkyZUqWL1+ez372s3nb296WqVOn5tZbb82ZZ56Za665JsnrTzy88cYbs2LFipx++ukZM2ZMli1blve85z1eeQAAJWo6Cp544onMnTs3tVottVotN998c5Lk4x//eO65557ccsst2bdvXz71qU9l165dee9735uHHnro6HsUJMnq1aszbNiwXH/99Tlw4EAWLFiQtWvXDtzfCgBoWq3+Zm82MMhs2bIlM2fOzObHH/fwAQA04T8fPti8efOvPIb67AMAIIkoAAAKogAASCIKAICCKAAAkogC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ABREAQCQRBQAAIWKPdHQixIBoDmNHzcrFQW14kWJAEBjmjluevgAAEhSuTMF3qUAAJrRzHHTmQIAIIkooAHr1q0re4Qhy96Xx96Xx96XRxTwK61bv77sEYYse18ee18ee1+eSj2nwAsSy/PL9r12jK8xMOxveU6Gva/qfbSKMw9WzeylMwW8Je64MLi5j9KMip0p8NHJZbDv5bH35bH35bH3A+uk++jk/fv3J0l+8IMfxIsST7zdu3dny5bvlj3GkGTvy2Pvy2PvB9brx87/fyw9llq9Xh/0Z5f+/u//PosXLy57DACorC996Uv56Ec/esw1lYiCHTt2ZMOGDZk6dWpGjhxZ9jgAUBn79+/Pc889l/nz52f8+PHHXFuJKAAAjj+vPgAAkogCAKAgCgCAJKIAACiIAgAgSUWiYO3atZk2bVpGjhyZOXPm5PHHHy97pJPOxo0bc/XVV2fy5MlpaWnJgw8++IY1K1euzKRJkzJq1KhcddVV6e7uLmHSk8vnPve5zJo1K+3t7eno6Mi1116bH/7wh29YZ+8H3he+8IVMnz49Y8eOzdixY3PZZZfl61//er819v3E+LM/+7O0tLRkxYoV/a63/yfeoI+C+++/PzfffHNuv/32fPe738306dMzf/787Nixo+zRTip9fX25+OKLc9ddd6VWe+O7Rq5atSp33nln7r777jz22GMZPXp05s+fn4MHD5Yw7clj48aN+b3f+708+uij+cY3vpFDhw7lgx/8YL93HrP3x8eUKVOyatWqbNmyJZs3b84HPvCBXHPNNdm2bVsS+36iPP7447n77rszffr0ftfb/5LUB7nZs2fXly1bdvT/HzlypD558uT6qlWrSpzq5Far1epf/epX+103ceLE+h133HH0/+/evbs+YsSI+v3333+ixzupvfTSS/VarVbfuHHj0evs/Ykzbty4+j333FOv1+37ifDKK6/UzzvvvHpXV1f9/e9/f/2mm246+jX7X45Bfabg0KFD2bx5c+bNm3f0ulqtliuvvDKbNm0qcbKhZfv27enp6el3O7S3t2f27NluhwG2a9eu1Gq1jBs3Lom9P1GOHDmS9evXZ9++fbnsssvs+wmydOnS/OZv/mY+8IEP9Lve/pdnUH8g0o4dO3L48OF0dHT0u76joyNPP/10SVMNPT09PanVam96O/T09JQ01cmnXq9n+fLlufzyy3PRRRclsffH27//+7/n0ksvzauvvpoxY8bkH//xH3P++edn06ZN9v04W79+fZ588sk88cQTb/ia3/vyDOoogKFkyZIleeqpp/Ktb32r7FGGjAsuuCBbt27N7t2788ADD+RjH/tYHnnkkbLHOum98MILWb58eb7xjW+ktbW17HH4BYP64YPx48dn2LBh6e3t7Xd9b29vOjs7S5pq6Ons7Ey9Xnc7HEef/vSn87WvfS0PP/xwJk6cePR6e398DR8+POecc04uueSS/Omf/mmmT5+eNWvW2PfjbPPmzXnppZcyY8aMtLa2prW1Nd/85jezZs2atLW1paOjw/6XZFBHQWtra2bOnJmurq6j19Xr9XR1deWyyy4rcbKhZdq0aens7Ox3O+zZsyePPvqo22EAfPrTn85Xv/rV/Ou//mvOOuusfl+z9yfWkSNHcuDAAft+nF155ZX5/ve/nyeffDJbt27N1q1b8xu/8RtZvHhxtm7dmnPOOcf+l2TYbbfddlvZQxxLe3t7Vq5cmSlTpuSUU07JZz7zmWzdujV//dd/ndGjR5c93kmjr68v27ZtS09PT/7qr/4qs2bNysiRI3Po0KGMHTs2hw8fzuc+97lcdNFFOXjwYJYtW5YDBw7kL/7iLzJs2LCyx6+sJUuW5L777ssDDzyQiRMnpq+vL319fRk+fHiGD3/90T17f3z80R/9Udra2pK8fjp79erVue+++/Lnf/7nmTZtmn0/jtra2jJhwoR+l/vuuy/nnHNOFi9enMTvfWnKfOlDo9auXVs/++yz6yNGjKjPmTOn/vjjj5c90knn4YcfrtdqtXpLS0u/yyc/+cmja/74j/+4PnHixPrIkSPrH/zgB+vPPPNMiROfHN5sz1taWup/+7d/22+dvR94N954Y33atGn1ESNG1Ds6OupXXXVVvaurq98a+37izJ07t99LEut1+1+GWr1er5cdJgBA+Qb1cwoAgBNHFAAASUQBAFAQBQBAElEAABREAQCQRBQAAAVRAAAkEQUAQEEUAABJRAEAUPh/HVmGNhVZlJwAAAAASUVORK5CYII=",
      "text/plain": [
       "PyPlot.Figure(PyObject <matplotlib.figure.Figure object at 0x7f0c8999e128>)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "PyObject <matplotlib.image.AxesImage object at 0x7f0c89b0c710>"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# First let's view an inline out of the \"real\" seismic data:\n",
    "\n",
    "seismic, seismic_h = SeisRead(\"dat/image\"); # load data\n",
    "SeisPlot(seismic[:,:,1], cmap = \"seismic\")  # plot data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAgUAAAIOCAYAAAAoW37OAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAPYQAAD2EBqD+naQAAGMZJREFUeJzt3X+Q1XXd9/HXWXZXkZslCdoF/MFi468sULoBMVNEXHQMx9ExS8Yf4x/OoDGEVzY1SdrYGNM1MaQwxnRpOabY6KSWKXO7dyQViaCSTUZuYubl7Co2SC0GKuf+o0877a0XsrnLceHxmNkZ+X4/5/A+n8XZ537PObuVarVaDQCw36ur9QAAwPuDKAAAkogCAKAQBQBAElEAABSiAABIIgoAgEIUAABJRAEAUIgCACBJjaNg2bJlaW1tzdChQzNt2rQ8/vjjtRwHAPZrNYuCu+++O1dffXWuv/76PPnkk5k4cWLa2tqyZcuWWo0EAPu1Sq1+IdK0adMyderULF26NElSrVZz6KGHZv78+bnmmmtqMRIA7NdqcqXgjTfeyIYNGzJz5syeY5VKJaeffnrWrl1bi5EAYL9XX4u/dMuWLXnrrbfS3Nzc63hzc3M2bdr0jutXrVqV8ePHZ+jQoXtrTAAY9F5//fU8//zzaWtry6hRo3a7tiZR0FerVq3K3Llzaz0GAAxad9xxRy666KLdrqlJFIwaNSpDhgxJV1dXr+NdXV1paWl52/rx48cnSb7/6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AAKUQAAJBEFAEAhCgCAJKIAAChEAQCQRBQAAIUoAACSiAIAoBAFAEASUQAAFKIAAEgiCgCAQhQAAElEAQBQiAIAIIkoAAAKUQAAJBEFAEAhCgCAJKIAAChEAQCQRBQAAIUoAACSiAIAoBAFAEASUQAAFKIAAEgiCgCAQhQAAElEAQBQiAIAIIkoAAAKUQAAJBEFAEAhCgCAJKIAAChEAQCQRBQAAIUoAACSiAIAoOhzFKxZsyZz5szJuHHjUldXlwceeOBtaxYtWpSxY8fmoIMOyqxZs9LR0dHr/I4dO3LllVdm1KhRGT58eM4///y8/PLL//6jAADesz5HQXd3dyZNmpTly5enUqm87fzixYtz8803Z8WKFVm3bl2GDRuWtra27Ny5s2fNggUL8uCDD+bee+/No48+mpdeeinnnXfee3skAMB7Ut/XG8yePTuzZ89OklSr1bedX7p0aa699tqcffbZSZLbb789zc3Nue+++3LBBRdk27ZtufXWW7Ny5cqccsopSZLbbrstxxxzTNatW5cpU6a8l8cDAPyb+vU1BZs3b05nZ2dmzpzZc6ypqSlTp07N2rVrkyTr16/Pm2++2WvNUUcdlcMOO6xnDQCw9/VrFHR2dqZSqaS5ubnX8ebm5nR2diZJurq60tjYmKampv9xDQCw93n3AQCQ5N94TcHutLS0pFqtpqurq9fVgq6urhx//PE9a3bu3Jlt27b1ulrQ1dWVlpaW3d7/57/9k3zgfx3Y69iFp0/MZ2ZN6sdHAQCD013/56msfGRjr2Nb//b3Pb59v0ZBa2trWlpa0t7eno997GNJkm3btuWxxx7LlVdemSSZPHly6uvr097ennPPPTdJsmnTprzwwgs58cQTd3v/S+afnROOGtefIwPAPuMzsya97RvlJzb9dz5++U17dPs+R0F3d3c6Ojp63nnw3HPPZePGjRk5cmQOPfTQLFiwIDfccEM+/OEPZ/z48bn22mtzyCGH5JxzzknyjxceXn755Vm4cGEOPvjgDB8+PPPnz89JJ53knQcAUEN9joL169dnxowZqVQqqVQqufrqq5Mkl1xySW699dZcc8012b59e6644ops3bo1J598ch566KE0Njb23MeS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7vvfMmDGj11sSq1X7XwuVarVarXWYAAC1975+TQEAsPeIAgAgiSgAAApRAAAkEQUAQCEKAIAkogAAKEQBAJBEFAAAhSgAAJKIAgCg+H9D6clDWtp6FgAAAABJRU5ErkJggg==",
      "text/plain": [
       "PyPlot.Figure(PyObject <matplotlib.figure.Figure object at 0x7f0c89b26320>)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "PyObject <matplotlib.image.AxesImage object at 0x7f0c892efd30>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Then let's assume we've picked a velocity model\n",
    "# and converted it to interval velocities.\n",
    "# We'll assume there are interpretive errors in\n",
    "# the model.\n",
    "\n",
    "# An inline from our picked vel model looks like this:\n",
    "\n",
    "vel_initial, vel_h = SeisRead(\"dat/vel_incorrect\"); # read data\n",
    "SeisPlot(vel_initial[:,:,1], cmap = \"magma\")        # plot data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "grep: ../dat/vel_correct: No such file or directory\n"
     ]
    },
    {
     "ename": "LoadError",
     "evalue": "LoadError: LoadError: failed process: Process(`grep in= ../dat/vel_correct`, ProcessExited(2)) [2]\nwhile loading /home/gram/tle_fwi/mod/modeler.jl, in expression starting on line 11\nwhile loading In[4], in expression starting on line 5",
     "output_type": "error",
     "traceback": [
      "LoadError: LoadError: failed process: Process(`grep in= ../dat/vel_correct`, ProcessExited(2)) [2]\nwhile loading /home/gram/tle_fwi/mod/modeler.jl, in expression starting on line 11\nwhile loading In[4], in expression starting on line 5",
      "",
      " in pipeline_error at process.jl:568",
      " in readbytes at process.jl:515",
      " in readall at process.jl:520",
      " in SeisRead at /home/gram/.julia/v0.4/Seismic/src/Utils/SeisRead.jl:33",
      " in include at ./boot.jl:261",
      " in include_from_node1 at ./loading.jl:320"
     ]
    }
   ],
   "source": [
    "# Obviously, this model is incorrect, or there would be three\n",
    "# seismic events in the section. Let's forward model this \n",
    "# incorrect vel model and view the output modeled seismic:\n",
    "\n",
    "include(\"mod/modeler.jl\");                                   # model seismic from our bad vels\n",
    "seis_incorrect, seismic_h = SeisRead(\"dat/image_incorrect\"); # load data\n",
    "SeisPlot(seis_incorrect[:,:,1], cmap = \"seismic\")            # plot data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "3D Poststack full waveform inversion algorithm\n",
      "\n",
      "\n",
      "In this program FWI updates a velocity model one sample at a time,\n",
      "one trace at a time. The velocity sample is perturbed positively,\n",
      "negatively, and not at all. Then the algorithm models new seismic\n",
      "from all three of the perturbed velocity models, and compares them to\n",
      "the input (real) seismic data. Whichever perturbation generates the\n",
      "least amount of error is chosen to be correct, and input into the \n",
      "updated velocity model.\n",
      "This algorithm accepts six inputs in the following order:\n",
      "\n",
      "\t1. Initial velocity model\n",
      "\t2. Poststack 3D seismic volume in Seis format\n",
      "\t3. One dimensional wavelet in Seis format\n",
      "\t4. Output file name (updated vel model in Seis format)\n",
      "\t5. Velocity update increment percentage in decimal\n",
      "\t6. Maximum number of velocity update iterations\n",
      "\t7. Verbosity (see note)\n",
      "\n",
      "If verbose is 0 operation is silent. If verbose is 1 updates will\n",
      "print to stdout. If verbose is 2 debugging info will print to stdout.\n",
      "Here is an example to get you started on the syntax:\n",
      "\n",
      "\n",
      "fwi(\"../dat/vel_incorrect\", \"../dat/image\", \"../dat/wav\", \"../dat/updated_vel\", .1, 5, 0)\n",
      "\n",
      "\n",
      "Please note this algorithm is written for clarity not speed, so\n",
      "use forgivingly small velocity models.\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "grep: ../dat/vel_incorrect: No such file or directory\n"
     ]
    },
    {
     "ename": "LoadError",
     "evalue": "LoadError: failed process: Process(`grep in= ../dat/vel_incorrect`, ProcessExited(2)) [2]\nwhile loading In[5], in expression starting on line 12",
     "output_type": "error",
     "traceback": [
      "LoadError: failed process: Process(`grep in= ../dat/vel_incorrect`, ProcessExited(2)) [2]\nwhile loading In[5], in expression starting on line 12",
      "",
      " in pipeline_error at process.jl:568",
      " in readbytes at process.jl:515",
      " in readall at process.jl:520",
      " in SeisRead at /home/gram/.julia/v0.4/Seismic/src/Utils/SeisRead.jl:33",
      " in fwi at /home/gram/tle_fwi/fwi/fwi.jl:37"
     ]
    }
   ],
   "source": [
    "# Therefore, if we tried to migrate with our bad velocity \n",
    "# model, we'd get a kinematically inaccurate result. Hence\n",
    "# we need to improve our velocity model somehow. So let's\n",
    "# use full waveform inversion.\n",
    "\n",
    "# Let's input our poorly picked velocity model and the \n",
    "# seismic data into an FWI algorithm and take a look\n",
    "# at the updated velocity model to see if there was any\n",
    "# improvement:\n",
    "\n",
    "include(\"fwi/fwi.jl\")                            # prep deps\n",
    "fwi(\"dat/vel_incorrect\", \"dat/image\", \n",
    "\"dat/wav\", \"dat/updated_vel\", .03, 5, 0);     # FWI algorithm\n",
    "\n",
    "vel_updated, vel_h = SeisRead(\"dat/updated_vel\") # load data\n",
    "SeisPlot(vel_updated[:,:,1], cmap = \"magma\")        # plot data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAgUAAAIOCAYAAAAoW37OAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAPYQAAD2EBqD+naQAAGJpJREFUeJzt3X2Q1XXd//HXWZYVJJYkaBfwhsXGuyxQGsC7FBEXHcNxcIwrGW/GP5wBYwjKpiZJGhtj6hdDimNOF5ZjCo1OapkyP/eKpCIRVLLJyE3NvJxdxQbJxUDl/P7o00770xBylyPweMzsDHy/n3P2fT4HZp97bnYr1Wq1GgDggFdX6wEAgPcHUQAAJB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QUAQCEKAIAkogAAKEQBAJBEFAAAhSgAAJKIAgCgEAUAQBJRAAAUogAASCIKAIBCFAAASUQBAFCIAgAgiSgAAApRAAAkEQUAQFFf6wH2ROWQQakMH1zrMQBgn1HZ9vpur923omDU0FTGfLjWYwDAPqPy5pu7vXbfioL6fqn036dGBoCaqtT32+21XlMAACQRBQBAIQoAgCSiAAAoRAEAkEQUAACFKAAAkogCAKAQBQBAElEAABSiAABIIgoAgEIUAABJRAEAUIgCACCJKAAAClEAACQRBQBAIQoAgCSiAAAoRAEAkEQUAACFKAAAkogCAKAQBQBAElEAABSiAABIIgoAgEIUAABJRAEAUIgCACCJKAAAClEAACQRBQBAIQoAgCSiAAAoRAEAkEQUAACFKAAAkogCAKAQBQBAElEAABSiAABIIgoAgEIUAABJRAEAUIgCACCJKAAAClEAACQRBQBAIQoAgCSiAAAoRAEAkEQUAACFKAAAkogCAKAQBQBAElEAABSiAABIIgoAgEIUAABJRAEAUIgCACCJKAAAClEAACQRBQBAIQoAgCSiAAAoRAEAkEQUAACFKAAAkogCAKAQBQBAElEAABSiAABIIgoAgGKPo2DNmjWZPn16Ro0albq6utx3331vW7Nw4cKMHDkyBx98cKZOnZr29vYe57dv3545c+Zk2LBhGTx4cC688MK89NJL//mtAADesz2Ogq6urowbNy433XRTKpXK284vXrw4N954Y2655ZasW7cugwYNSmtra3bs2NG9Zt68ebn//vtz99135+GHH86LL76YGTNmvLdbAgC8J/V7eoFp06Zl2rRpSZJqtfq280uXLs0111yT8847L0ly2223pampKffcc08uuuiibN26NcuXL8+KFSty+umnJ0luvfXWHHvssVm3bl0mTJjwXm4PAPAf6tXXFDz77LPp6OjIlClTuo81NjZm4sSJWbt2bZJk/fr1efPNN3usOfroo3P44Yd3rwEA9r5ejYKOjo5UKpU0NTX1ON7U1JSOjo4kSWdnZxoaGtLY2Phv1wAAe593HwAASf6D1xTsSnNzc6rVajo7O3s8WtDZ2ZkTTjihe82OHTuydevWHo8WdHZ2prm5eZfX/7nv/DQf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ZceOHZk7d262b9+e73znO+nXr1+tx99nzZ49O3fccUfuuuuujBgxIl1dXenq6kp9fX3q6//x7J697xtf/vKX09DQkOQfD2cvWbIkd9xxR775zW+mpaXFvvehhoaGDB8+vMfHHXfckTFjxmTWrFlJ/LuvmVq+9WF3LVu2rHrEEUdUBwwYUJ00aVL10UcfrfVI+53Vq1dXK5VKta6ursfH5Zdf3r3mq1/9anXEiBHVgQMHVs8+++zq008/XcOJ9w/vtOd1dXXVH/zgBz3W2fved8UVV1RbWlqqAwYMqDY1NVWnTp1abWtr67HGvu89kydP7vGWxGrV/tdCpVqtVmsdJgBA7b2vX1MAAOw9ogAASCIKAIBCFAAASUQBAFCIAgAgiSgAAApRAAAkEQUAQCEKAIAkogAAKP4fziXHEiDSKaUAAAAASUVORK5CYII=",
      "text/plain": [
       "PyPlot.Figure(PyObject <matplotlib.figure.Figure object at 0x7f0c892c9be0>)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "PyObject <matplotlib.image.AxesImage object at 0x7f0c84b77710>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# We can see here that the vel model has been improved considerably\n",
    "# by full waveform inversion. For comparison, let's view\n",
    "# the insitu velocities.\n",
    "# (This is the model the author used to create the \"real\" seismic)\n",
    "\n",
    "\n",
    "vel_true, vel_h = SeisRead(\"dat/vel_correct\"); # read data\n",
    "SeisPlot(vel_true[:,:,1], cmap = \"magma\")         # plot data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# As you can see, the FWI updated vel model is very close\n",
    "# to the true velocities. In this case it's actually within 3%."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Julia 0.4.5",
   "language": "julia",
   "name": "julia-0.4"
  },
  "language_info": {
   "file_extension": ".jl",
   "mimetype": "application/julia",
   "name": "julia",
   "version": "0.4.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
